

<cfif Not IsDefined("session.id")>
		<cflocation url = "/ecada/" addToken = "no">
</cfif>
	
<cfif IsDefined("session.experiment")>
	<cfset experiment = session.experiment>
<cfelse>
	<cflocation url="/ecada/" addToken="No" >
</cfif>

<cfif IsDefined("form.submit")>

<cfelse>
	
	<cfinclude template= "/ecada/header.cfm">
	
	<cfoutput>
		<script type="text/javascript">
			$(document).ready(function(){
			//this function is defined in progressbar.cfm and is included in the header
				setProgressText("Question creator");
				setProgress(4);
			});
		</script>
	</cfoutput>
	<cfoutput>
	<fieldset>
		<legend>
			Question Bank
		</legend>
		<p>
			On this page you can specify questions that you might use more than once. If not please just press next! When you add a Question it will apear below with further options.
		</p>
		<table border=1>
			<cfquery datasource="exp" name="questions">
				SELECT q.*, qt.type
				FROM question q, qestiontype qt
				WHERE expid = #experiment.id#
				AND q.typeID = qt.id
				ORDER BY q.id
			</cfquery>
			<cfif questions.recordcount eq 0>
				<tr>
					<td colspan=3>
						There are no questions. Please click "Add Question" to add a question!
					</td>
				</tr>
			<cfelse>
				<tr>
					<th>
						ID
					</th>
					<th width="400px">
						Question Text
					</th>
					<th>
						Answer Type
					</th>
					<th>
						Options
					</th>
				</tr>

				<cfloop query="questions">
					<tr>
						<td>
							#id#
						</td>
						<td>
							#question#
						</td>
						<td>
							#type#
						</td>
						<td>
							<form method="post" action="delete/">
								<input type="hidden" name="DeleteID" value="#id#">
								<input type="submit" value="Delete">
							</form>
							<form method="post" action="edit/">
								<input type="hidden" name="EditID" value="#id#">
								<input type="submit" value="Edit">
							</form>
						</td>
					</tr>
				</cfloop>
			</cfif>
			<tr>
				<td colspan=3>
					<form method="post" action="add/">
						<input type="submit" value="Add Question">
					</form>
				</td>
			</tr>
		</table>
	</fieldset>
	<div style="width: 100%;">
		<div style="width: 10%; float: left;">
			<form method="post" action="./../Step-3">
				
				<input type="submit" value="Back"></input>
			</form>
		</div >
		<div style="width: 50%; float:left;">
			<form method="post" action="./../Step-5">
				
				<input type="submit" value="Next"></input>
			</form>
		</div>
	</div>

	</cfoutput>
	<cfinclude template= "/ecada/footer.cfm">
</cfif>



